package _08作业.t3;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class T3Client {
    public static void main(String[] args) throws IOException {
        System.out.println("客户端启动");
        //创建客户端socket
        Socket socket = new Socket("127.0.0.1",9999);

        while (true){

            //获取socket输出流
            OutputStream sos = socket.getOutputStream();
            Scanner sc = new Scanner(System.in);
            System.out.print("请输入信息：");
            String line = sc.nextLine();
            if (line == "exit")
            {
                break;
            }
            PrintStream ps = new PrintStream(sos);
            ps.println(line);


            //接收服务端信息
            InputStream sis = socket.getInputStream();
            InputStreamReader isr = new InputStreamReader(sis);
            BufferedReader br = new BufferedReader(isr);
            String readLine = br.readLine();
            System.out.println("服务端发来信息："+readLine);


        }


    }
}
